<template>
  <div class="footer-container">
    <!-- 全选区域 -->
    <div class="form-check form-check-inline">
      <input
        class="form-check-input"
        type="checkbox"
        id="fullCheck"
        value="option1"
        :checked="isfull"
        @change="onChange"
      />
      <label class="form-check-label" for="fullCheck">全选</label>
    </div>
    <div>
      <span>合计:</span><span class="amount">{{ amount.toFixed(2) }}元</span>
    </div>
    <button class="btn btn-primary btn-sf" :disabled="total === 0">
      结算({{ total }})
    </button>
  </div>
</template>

<script>
export default {
  name: 'EsFooter',
  emits: ['fullChange'],
  props: {
    //   商品总价格
    amount: {
      type: Number,
      default: 0,
    },
    // 商品总数量
    total: {
      type: Number,
      default: 0,
    },
    // 全选按钮选中状态
    isfull: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    //   当全选按钮选中状态改变时,向根组件发送最新的选中状态
    onChange(e) {
      this.$emit('fullChange', e.target.checked)
    },
  },
}
</script>

<style lang="less" scoped>
.footer-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: #fff;
  border-top: 1px solid #efefef;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  z-index: 999;
  align-items: center;
}

.amount {
  font-weight: bold;
  color: red;
}

.btn-sf {
  min-width: 90px;
  height: 38px;
  border-radius: 19px;
}
</style>
